POV-Ray : Newsgroups : povray.animations : Skeletal Animation Saga Continues : Skeletal Animation Saga Continues Server Time
3 May 2024 20:05:41 EDT (-0400)
  Skeletal Animation Saga Continues  
From: melo
Date: 15 Feb 2008 01:45:01
Message: <web.47b534b08e58508092254edf0@news.povray.org>
Well, I have been doing some cleaning up the code based on various
recommendations Chris had offered along the way.

Such as capitalizing the var names, getting my animation control joint rotation
arrays working smoothly across frames.

I felt brave enough to switch to moving joint rotation specifications per pose
(i.e Key_Frame) into separate files I can read during animation.

I have not managed to get too far.  I have kept my staged animation logic, let
me include 1st two stages for discussions sake, and describe the error I am
getting from POV-RAY, I have search the Wiki and Support to see if there is a
documented problem, I have not seen any.

My code will be further down.  In the first stage, that is, when clock is
between 0 and 1, I first draw the Humanoid in its pose 0, i.e default pose, in
which all of his joint rotations are zero and s/he is standing erect with arms
down her sides.
Then I read my walk01.pov file that contains the involved joint rotation vectors
as a triplet: Joint_name as a string, joint index as a float, and finally,
rotation  as a vector.  Joint_name string is just for information purposes.
Later, I could do a lookup to figure out the index.  For now, I am hardcoding
the index.

Well, the first time around, I can read the file correctly.  Move_Humanoid macro
builds the object Humanoid, and if any rotation vector in AVAR[1] is set,
rotates the segments associated with that rotation vector.

In the second stage of animation marked with #range(1, 2) statement, I attempt
to reread the walk01.pov file to know which pose to start the animation and
read walk03.pov to know which pose to end the animation.  However, during that
second attempt to reread the walk01.pov file which was read ok the first time,
the program crashes at the second line of the file claiming it could not be
read.



Here is the code
===============

#switch ( clock )

   #range( 0.0, 1.0 )
      //=== Key_Frame1: STRIDE LEFT
      #if ( clock = 0.0 ) // STAND STILL
         #declare Key_Frame = 0;
         #declare Action = 0.0; // Stand still
         #declare Human_Trans =
         transform {
            scale 1.5
            translate <0.0, -1.0, 0.0>
            rotate <0, 0, 0>
            };


         Move_Humanoid( Key_Frame, Action )
         #declare Humanoid_Still = Humanoid;
         object { Humanoid_Still transform Human_Trans }

      #else //=== Key_Frame1: STRIDE LEFT

         #declare Action = 1.11; // "Stride.LeftKey_Frame1
         #declare IBP = clock;   // In Between Position counter
         #declare Key_Frame = 1;

         // declare all AVARs associated with left stride
         #debug "In Key Frame 1 else about to read walk01 for the 1st time.\n"
         #fopen posFile "Walk01.pov" read
         #while (defined( PosFile ))
            #read (PosFile, Joint_Name, AVar_Ndx, Rot_Vector )
            #declare AVAR[1][AVar_Ndx] = Rot_Vector * IBP;
         #end



         #declare L_Step_Size = 1.5*Calculate_Step_Size( "L" );
         #declare Human_Trans_1_1_01 =
         transform {
            scale 1.5
            translate L_Step_Size*clock*z -1.0*y
            //rotate <20*IBP, 0, 0>
            };


         Move_Humanoid( Key_Frame, Action )
         #declare Humanoid_1_1_01 = Humanoid;
         object{ Humanoid_1_1_01 transform Human_Trans_1_1_01 }

         // Here I observe another problem, even though now a number of
         // rotation vectors are set in AVAR[1], Move_Humanoid should have
         // rotated some of the joints, the only thing I see happening is the
         // transformation getting applied to my Humanoid in his defualt pose??
      #end
   #break

   #range( 1.0, 2.0 )
      //== Key_Frame 3  page 113
      #declare Key_Frame = 3;
      #declare Action = 1.13; // "Stride.Left.Key_Frame3
      #declare IBP = clock - 1;  // In-Between Position counter

      // load previous pose into AVAR[0]
      #debug "In key_Frame 3. About to open walk01 to load previous pose\n"
      #fopen Pos2File "Walk01.pov" read
      #while (defined(Pos2File) )
         #read (Pos2File, Joint_Name, AVar_Ndx, Rot_Vector )
         #declare AVAR[0][AVar_Ndx] = Rot_Vector;
      #end

      // load current target pose into AVAR[1] elements
      #debug "In KeyFrame 3. About to open walk03 to load current pose\n"
      #fopen Pos3File "walk03.pov" read
      #while (defined(Pos3File) )
         #read (Pos3File, Joint_Name, AVar_Ndx, Rot_Vector )
         #declare AVAR[1][AVar_Ndx] = Rot_Vector;
      #end

      // now interpolate from prev pose AVAR[0] to current pose AVAR[1]
      #declare JointNdx = 0;
      #while ( JointNdx < 22 )
        #declare AVAR[1][JointNdx]=IRV(AVAR[1][JointNdx],AVAR[0][JointNdx],IBP);
        #declare JointNdx = JointNdx + 1;
      #end

      #declare L_Step_Size = 1.5*Calculate_Step_Size( "L" );
      #declare Human_Trans_1_1_03 =
      transform {
         scale 1.5
         translate L_Step_Size*clock*z -1.0*y //<0.0, 1.0, 0.0 >
         };
      Move_Humanoid( Key_Frame, Action )
      #declare Humanoid_1_1_03 = Humanoid;
      object{ Humanoid_1_1_03 transform Human_Trans_1_1_03 }
   #break

//=== Here is walk01.pov file
"L_Hip_Ind",3,<-40,0,0>
"L_Knee_Ind",4,<0,0,0>
"L_Ankle_Ind",5,<50,0,0>
"R_Hip_Ind",13,<45, 0, 0>
"R_Knee_Ind",14,<5, 0, 0>
"L_Elbow_Ind",10,<2, 0, 0>
"R_Acromioclav_Ind",18,<0, 10, 0>
"L_Acromioclav_Ind",8,<0, -10, 0>
"R_Acromioclav_Ind",18,<-40, 0, 20>
"R_Elbow_Ind",20,<-90, 0, 0>
"R_Ball_Ind",17,<-60, 0, 0>
"Lower_Back_Ind",2,<-0,0,0>
"HumanoidRoot_Ind",0,<20, 0, 0>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.